home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / amiga.free / sorgenti vari / wolfedit2 2.0.4 source.sit / WolfEdit2 2.0.4 Source / UMapCellsView.p < prev    next >
Text File  |  1995-11-08  |  2KB  |  102 lines

  1. unit UMapCellsView;
  2.  
  3. interface
  4.     uses
  5.         UGoof, UList, UMapCells, UWolfDoc;
  6.  
  7.     type
  8.  
  9.         TMapCellsView = object(TList)
  10.                 fCells: TMapCells;
  11.                 fMapList: TMapListDoc;
  12.                 procedure IMapCellsView (itsCells: TMapCells; opts: ListOptions; itsMapList: TMapListDoc);
  13.                 procedure DrawCell (cell: Point; r: Rect; var hilite: boolean);
  14.                 override;
  15.                 function GetCellForDrawing (cell: Point): MapCell;
  16.             end;
  17.  
  18.     procedure IUMapCellsView;
  19.  
  20. implementation
  21.  
  22.     procedure IUMapCellsView;
  23.     begin
  24.     end;
  25.  
  26. {------------------------------- TMapCellsView Methods ------------------------------}
  27.  
  28.     procedure TMapCellsView.IMapCellsView (itsCells: TMapCells; opts: ListOptions; itsMapList: TMapListDoc);
  29.         var
  30.             cellSize, borderSize: Point;
  31.             r: Rect;
  32.     begin
  33.         SetPt(cellSize, 16, 16);
  34.         SetPt(borderSize, 1, 1);
  35.         if itsCells <> nil then
  36.             itsCells.GetBounds(r)
  37.         else
  38.             SetRect(r, 0, 0, 17 * 64, 17 * 64);
  39.         IListX(cellSize, borderSize, r, opts);
  40.         fCells := itsCells;
  41.         fMapList := itsMapList;
  42.     end;
  43.  
  44.     procedure PlotQuarteredWall (mapList: TMapListDoc; wall, mq: integer; r: Rect);
  45.         var
  46.             oldClip, newClip: RgnHandle;
  47.             i, j: integer;
  48.             s: Rect;
  49.     begin
  50.         oldClip := NewRgn;
  51.         newClip := NewRgn;
  52.         GetClip(oldClip);
  53.         OpenRgn;
  54.         for i := 0 to 1 do
  55.             for j := 0 to 1 do
  56.                 if BAND(mq, BSL(1, j * 2 + i)) = 0 then begin
  57.                         SetRect(s, i, j, i + 1, j + 1);
  58.                         FrameRect(s);
  59.                     end;
  60.         CloseRgn(newClip);
  61.         SetRect(s, 0, 0, 2, 2);
  62.         MapRgn(newClip, s, r);
  63.         SectRgn(oldClip, newClip, newClip);
  64.         SetClip(newClip);
  65.         mapList.PlotWall(wall, r);
  66.         SetClip(oldClip);
  67.         DisposeRgn(oldClip);
  68.         DisposeRgn(newClip);
  69.     end;
  70.  
  71.     procedure TMapCellsView.DrawCell (cell: Point; r: Rect; var hilite: boolean);
  72.         var
  73.             code: MapCell;
  74.             s: string[8];
  75.     begin
  76.         code := GetCellForDrawing(cell);
  77.         if (code.wall = 0) or (code.missingQuarters <> 0) then
  78.             EraseRect(r);
  79.         if code.wall <> 0 then
  80.             if code.missingQuarters <> 0 then
  81.                 PlotQuarteredWall(fMapList, code.wall, code.missingQuarters, r)
  82.             else
  83.                 fMapList.PlotWall(code.wall, r);
  84.         if code.obj <> 0 then
  85.             fMapList.PlotObject(code.obj, code.dir, r);
  86.         if code.area <> 0 then begin
  87.                 fMapList.PlotSound(r);
  88.                 TextFont(geneva);
  89.                 TextSize(9);
  90.                 TextFace([]);
  91.                 s := StringOf(code.area : 1);
  92.                 MoveTo(r.right - StringWidth(s), r.bottom - 1);
  93.                 DrawString(s);
  94.             end;
  95.     end;
  96.  
  97.     function TMapCellsView.GetCellForDrawing (cell: Point): MapCell;
  98.     begin
  99.         GetCellForDrawing := fCells.GetCell(cell);
  100.     end;
  101.  
  102. end.